package com.t.bricks.bussiness.controller.simplemonitor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.t.bricks.bussiness.model.monitor.MonitorInfo;
import com.t.bricks.bussiness.service.simplemonitor.SimpleMonitorService;
import com.t.bricks.model.MsgEmity;

@Controller
@RequestMapping("/simple/monitor/")
public class SimpleMonitorController {
	
	@Autowired
	private SimpleMonitorService simpleMonitorService;
	
	/**
	 * 应用程序密钥
	 */
	@Value("${app.key:未配置app.key}")
	private String appKey;
	
	/**
	 * 查询监控程序信息
	 * @return
	 */
	@RequestMapping(method={RequestMethod.POST}, value="/search")
	@ResponseBody
	public MsgEmity search() {
		return simpleMonitorService.search();
	}
	
	/**
	 * 关闭被监控程序信息
	 * @param sId 当前记录编号
	 * @return
	 */
	@RequestMapping(method={RequestMethod.POST}, value="/shutdown")
	@ResponseBody
	public MsgEmity shutdown(String sId) {
		return simpleMonitorService.shutdown(sId);
	}
	
	/**
	 * 关闭被监控程序信息
	 * @param sId 当前记录编号
	 * @return
	 */
	@RequestMapping(method={RequestMethod.POST}, value="/load/url")
	@ResponseBody
	public MsgEmity loadUrl(@RequestBody MonitorInfo monitorInfo) {
		return simpleMonitorService.loadUrl(monitorInfo);
	}
	
}
